package com.teamin.entity;

import com.teamin.service.FileService;
import com.teamin.service.impl.FileServiceImpl;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 任务评论实体类
 */

@Component
public class SimpleImgCommentEntity {

    @ApiModelProperty(value = "评论 ID")
    private Long commentId;

    @ApiModelProperty(value = "用户ID评论的时间")
    private Date createTime;

    @ApiModelProperty(value = "评论的类型  评论的类型 1 为文本信息,2表图片(必)")
    private int contentType;

    @ApiModelProperty(value = "评论的内容")
    private String content;

    @ApiModelProperty(value = "文件名")
    private String fileName;

    @ApiModelProperty(value = "文件的地址")
    private String fileUrl;

    @ApiModelProperty(value = "缩略图地址")
    private String thumbnailUrl;

    @ApiModelProperty(value = "文件的UUID")
    private String uuid;

    @ApiModelProperty(value = "文件后缀")
    private String suffix;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        FileService fileService = new FileServiceImpl() ;
        this.uuid = uuid;
        if(getContentType() == CommentEntity.COMMENT_TYPE_IMG){
            setFileUrl(fileService.getFileUrl(getUuid(),getFileName()));
            if(fileService.supportThumbnailFormat(getSuffix()))
                setThumbnailUrl(fileService.getFileThumbnail(getUuid(),getFileName()));
        }

    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public String getThumbnailUrl() {
        return thumbnailUrl;
    }

    public String getSuffix() {
        return suffix;
    }

    public Long getCommentId() {
        return commentId;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public void setThumbnailUrl(String thumbnailUrl) {
        this.thumbnailUrl = thumbnailUrl;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public int getContentType() {
        return contentType;
    }

    public String getContent() {
        return content;
    }

    public void setCommentId(Long commentId) {
        this.commentId = commentId;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public void setContentType(int contentType) {
        this.contentType = contentType;
    }

    public void setContent(String content) {
        this.content = content;
    }
}
